home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
suite3d
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
10KB
Path: seq!spell
From: Charles Patton <charliep@hpcvrs.cv.hp.com>
Subject: v01i017: suite3d - 3D Graphing Suite v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu
Checksum: 958952063 (verify with brik -cv)
Submitted-by: Charles Patton <charliep@hpcvrs.cv.hp.com>
Posting-number: Volume 1, Issue 17
Archive-name: suite3d/part01
BEGIN_DOC Suite3D.doc
@ Version 1.0 @
_Introduction_
The programs contained in this document comprise a suite of 3D
graphing/viewing utilities for the HP-48 (an HP-28 version will be
forthcoming provided sufficient interest.)
We had several requirements to consider in creating these
programs. Our aims were that they be (1) purely user code, (2)
relatively short, and (3) psychologically effective. Aims (1) and (2)
are due to our target audience of educators, many of whom have little
contact with technology beyond their use of the HP-48 or HP-28. We
expect that, in many situations, one user will obtain the code in
printed form, enter it into their machine, and transmit it to others
via the infrared I/O.
In exploring visualization techniques on a variety of machines we
found that increasing "realism" (read: ray-traced, Phong-shaded,
hidden-line, etc.) in the graphical presentation of functions of two
variables did not necessarily correlate with increasing ease of
comprehension. These programs represent the results of some of these
experiments (including time-to-completion as an important factor).
We invite you to try them out and experiment yourself. All
suggestions, additions, corrections, insights, commentary, and
criticisms are welcome.
_Organization_
Analogous to the built-in plotting routines, all the Suite3D
programs assume that the function of interest is stored in EQ.
Further, they assume that the function is represented as an expression
in the variables 'X' and 'Y' (e.g. u,v -> sin(u+v) is represented as
'SIN(X+Y)' in EQ). Insure that 'X' and 'Y' are formal (no variables
'X' and 'Y' along the current path).
The viewing window is controlled (as usual) by PMIN and PMAX (or
XRNG and YRNG, though these may be inappropriately named for some
Suite3D programs.)
Some of the programs have an associated <descriptor>PAR variable
analogous to PPAR. Default versions are supplied in this document.
The programs here are organized into a single directory for
convenience. Inter-dependence of the programs and other variables is
noted in the program description.
_Oversized PICTs_
With the sole exception of YVIEW, all of the programs have
assumed that the PICT grob has the default size. Moreover, some of the
parameters coded into the programs were determined experimentally. In
consequence, don't expect any miracles to occur with these programs if
an oversized PICT is used. While it is quite possible encode automatic
scaling from the size of the PICT, we didn't find it useful enough to
include. If anyone has additional insights into this issue, we'd
welcome their input.
_Descriptions of the Programs_
SlopeField:
The SlopeField program plots a lattice of line segments whose
slopes represent the function value at their centerpoint. Using
SlopeField to plot F(X,Y) allows your eye to pick out integral curves
of the differential equation dy/dx=F(x,y). It is quite useful in
understanding where the "arbitrary constant" in anti-derivatives comes
from.
psContour:
The psContour program (pseudo-contour) program uses SlopeField to
produce a fast contour plot of the current function. By plotting the
direction field perpendicular to the gradient of the function it
allows your eye to pick out the integral curves (contours) without
actually plotting them. The apparent contours are evenly spaced
visually and so give no information on how steep the graph is at any
particular point.
YView:
The YView program provides an oblique-view, perspective, 3D
surface plot (viewing toward increasing Y). The program assumes that
the variable VPAR contains the viewpoint coordinates, Xe, Ye, Ze,
together with view-volume bounds, Yfar and Ynear. VPAR, then, is
assumed to contain a list of numbers { Xe Ye Ze Yfar Ynear
hidden-line-p } where hidden-line-p is non-zero if you wish to use the
hidden-line facilities in the plot. If this is non-zero, RES (plotting
resolution) should be set to 0, or #2 for best effect. The XRNG and
YRNG (really "ZRNG" in this case) are to be adjusted as usual.
This is a simple "divide-by-depth" method for perspective
plotting where the viewplane is always 1 unit from the viewpoint and
is parallel to the x-z plane. Since the perspective transformation in
the case can be implemented by a simple change of coordinates,
plotting individual sections is no slower than ordinary plots.
Note: To abort this routine, press the [ON] key and then press
the [ENTER] key.
ShapeToShade:
The ShapeToShade program plots the function as a Phong-shaded
figure viewed from above with a light source in the "north west." It
assumes that the variable DPAR contains sixteen 4x4 GROBS to serve as
the dithering pattern. The dither patterns included are probably not the
best possible: insights along these lines are most welcome.
Movie:
The Movie program plots 8 cross-sections of the function plot
varying the Y-value from Yfar to Ynear (as recorded in VPAR, see
YView). Having plotted these, it calls the utility program, uSMOV
(utility-show-movie), to play these back in sequence repeatedly.
Note: To abort this routine in the plotting phase, press the [ON]
key and then press the [ENTER] key. To end the movie press any key
(e.g. [ENTER]).
uSMOV:
The uSMOV (utility show-movie) program takes <n> grobs from the
stack and shows them in sequence, thus producing a movie effect. It
can be stopped with any key press.
_Correspondence_
Correspondence on Suite3D suite be sent to Charles Patton at one of the
following addresses:
snail-mail:
M.S. 5U-L9
Hewlett-Packard Co.
1000 N.E. Circle Blvd.
Corvallis, OR 97330
e-mail:
charliep@cv.hp.com (for Internet hosts)
hplabs!hpcvrs!charliep (for UUCP hosts)
END_DOC
BYTES: #EEADh 3228.5
BEGIN_RPL Suite3D
%%HP: T(3)A(R)F(.);
DIR
SlopeField
\<< EQ
'PPAR(1)' EVAL C\->R
'PPAR(2)' EVAL C\->R
0 0 0 0 0 0 0
\-> der left bot right top hstp vstp hofs vofs x y d
\<< ERASE { # 0d # 0d } PVIEW
right left - 13 / 'hstp' STO
top bot - 8 / 'vstp' STO
hstp .4 * 'hofs' STO
vstp .4 * 'vofs' STO
bot vstp 2 / + top
FOR y
y 'Y' STO
left hstp 2 / + right
FOR x
x 'X' STO
der \->NUM 'd' STO
'IFTE(ABS(d*hofs)>vofs,
vofs/d+i*vofs,
hofs+i*hofs*d)' \->NUM
x y R\->C
DUP2 + 3 ROLLD SWAP - LINE
hstp
STEP
vstp
STEP
\>> {X Y} PURGE {} PVIEW
\>>
psContour
\<< EQ
\<< \-> dx dy 'IFTE(dy==0,MAXR,-dx/dy)' \>>
\-> eq slp
\<< IFERR
eq X \.d eq Y \.d
2 \->LIST 'slp' APPLY
{X Y } SHOW
STEQ
SlopeField
THEN
eq STEQ
ERRM DOERR
END eq STEQ
\>>
\>>
YView
\<< VPAR OBJ\->
@ include the (optional) hidden-line routine: @
\<< \-> K
\<< CASE K TYPE DUP 0 ==
THEN DROP
X K R\->C X -50 R\->C DUP2
LINE TLINE
K
END
1 ==
THEN K
END
K EVAL 1 \->LIST 'PRASE' APPLY
END
\>>
\>>
\-> Xe Ye Ze Yfar Ynear prase u hline
\<< 'EQ' RCL 'u' \-> eq u
\<< eq { 'X' '(X-Xe)*u+Xe' 'Y' 'u+Ye' } |
Ze - 'u' / Ze +
{ X u } SHOW COLCT
IF prase
THEN { & 'hline(&)' } \|vMATCH DROP
END
IFERR
'EQ' STO
'X' INDEP ERASE
Ynear Yfar - 8 /
\-> stp
\<<
Yfar Ye -
Ynear Ye -
FOR u
DRAW
IF
KEY
THEN
DROP
"outa here" DOERR
END stp
STEP
\>>
THEN eq STEQ ERRM DOERR
ELSE eq STEQ
END {} PVIEW
\>>
\>>
\>>
VPAR
{ 0 -.5 2 3.5 -.2 0}
ShapeToShade
\<< 'PPAR(1)' EVAL C\->R
'PPAR(2)' EVAL C\->R 0 0 0
\-> xmin ymin xmax ymax x y eq
\<< xmax xmin - 32 / ymax ymin - 15 / 'x' 'y'
\-> xstp ystp x y
\<< EQ DUP X \.d .4 - 2 ^ SWAP
Y \.d .4 - 2 ^ +
1 + -.5 ^ {X x Y y} | 'eq' STO
ERASE
{ # 0d # 0d } PVIEW # 0d ymin ymax
FOR y
# 0d xmin xmax
FOR x
DUP2 SWAP 2 \->LIST PICT SWAP
eq \->NUM
IF DUP TYPE 0 \=/
THEN DROP 1
END
15 * IP DPAR SWAP
16 - NEG GET REPL
4 + xstp
STEP
DROP 4 + ystp
STEP DROP
{} PVIEW
\>>
\>>
\>>
DPAR
{ GROB 4 4 00400000
GROB 4 4 00402000
GROB 4 4 00604000
GROB 4 4 00606000
GROB 4 4 00606010
GROB 4 4 10606080
GROB 4 4 90606080
GROB 4 4 90606090
GROB 4 4 60909070
GROB 4 4 E0909070
GROB 4 4 F09090E0
GROB 4 4 F09090F0
GROB 4 4 F090B0F0
GROB 4 4 F0B0D0F0
GROB 4 4 F0B0F0F0
GROB 4 4 F0F0F0F0
}
Movie
\<< PPAR EQ 'VPAR(4)' EVAL 'VPAR(5)' EVAL 0 0
\-> ppar eq yfar ynear ystp y
\<< 'y' 'y' STO
eq {X Y} SHOW {Y y} |
ynear yfar - 8 / 'ystp' STO
IFERR
STEQ
'X' INDEP
FUNCTION
0 yfar ynear
FOR y
ERASE DRAW PICT RCL SWAP 1 +
IF KEY
THEN DROP "outa here" DOERR
END
ystp
STEP
THEN
ppar 'PPAR' STO
eq STEQ
ERRM DOERR
END
ppar 'PPAR' STO
eq STEQ
\>> uSMOV
\>>
uSMOV
\<< \-> n
\<< {#0 #0} PVIEW
DO
n ROLL DUP PICT {#0 #0} ROT REPL
UNTIL
KEY
END DROP
n
\>>
\>>
EQ
'(Y^2*X-X^3)*.2'
PPAR
{ (-6.5,-3.1) (6.5,3.2) X # 4d (0,0) FUNCTION Y }
END
END_RPL